<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <meta name="format-detection"content="telephone=no, email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" /><!-- 删除苹果默认的工具栏和菜单栏 -->
    <meta name="apple-mobile-web-app-status-bar-style" content="black" /><!-- 设置苹果工具栏颜色 -->
    <meta name="renderer" content="ie-comp">
    <meta name="renderer" content="ie-stand">
    <meta name="renderer" content="webkit"> 
    <meta name="keywords" content="耀盛中国,耀盛智投,理财产品,智选财富,耀盛智投官网"/>
    <meta name="description" content="耀盛智投为耀盛中国旗下理财产品智选平台。专注于为大众富裕阶层、精英个人、中产阶级家庭、合规机构等提供定制化资产配置咨询推荐服务，帮助客户实现财富的增值。" />
    <title>提现</title>
    <script src="../lib/js/ftSize.js"></script>
    <link rel="stylesheet" href="../lib/css/_base.css">
    <link rel="stylesheet" type="text/css" href="../lib/css/personageset.css">
    <link rel="stylesheet" href="../lib/css/publicBubb.css">
</head>
<body>
    <h1 class="rem90R"><img src="../lib/images/left.png" class="leftImg" onClick="prevAttectation()">申请提现</h1>
    <div class="sq_bank" id="bankImg">
       
       <!--  <img src="./../lib/images/zhaoshang.png" >
        <span>招商银行（6225****7405）</span>   -->  
    </div>
    <div class="withdraw_box">
        <p>提现金额</p>
        <div class="withdraw_number">
            <span>¥</span>
            <input type="text" id="withdrawMoney" placeholder="最小提现金额100元" class="je_text"  maxlength="13" onkeydown="if(event.keyCode==32) return false">
           <!--  <input type="text" id="withdrawMoney" placeholder="最小提现金额100元" class="je_text" oninput="this.value=this.value.replace(/\D/g,'').replace(/^0+(?=\d)/,'')" maxlength="12"> -->
        </div>
    </div>
    <div class="all_number">
        <p>可用金额<span id="wpavailableAmount"></span>元</p>
        <i onClick="allAmount()">全部提现</i>
    </div>
    <div class="warnMoney" id="warnMoney"></div>
    <div class="F_btn_n1" onClick="withdrawalShow()">确认提现</div>

<!-- 支付密码弹窗 -->
    <div class="maskWrap" id="withdrawalMask" style="display: none">
        <div class="maskLayer">
            <div class="maskCross" onClick="withdrawalHide()"></div>
            <div class="maskTitleed">请输入交易密码</div>
            <div class="maskItemed"><input type="password" value="" class="maskInput" placeholder="请输入交易密码" id="maskInput" minlength="6"></div>
            <div class="maskWarning" id="maskWarneding"></div>
            <div class="maskbtnGroupes">
                <span class="winBg"  onClick="okWithdrawal()" style="border-radius:0 0 .08rem .08rem;"> 确定</span>
            </div>  
        </div>
    </div>
<!-- 提现成功 -->
<div class="maskWrap" id="rechargeCash" style="display: none">
    <div class="maskLayer">
         <div class="maskImg"></div>
        <div class="maskTitle">您的提现申请已提交</div>
        <div class="maskContent">提现时间为T+1,（节假日顺延）</div>
        <div class="maskbtnGroup">
            <a href="index.html"> <span class="winBg"> 确定</span></a>
        </div>  
    </div>
</div>
<script src="../lib/js/jquery.min.js"></script>    
<script src="../lib/js/public-header.js"></script> 
<script>
    let userId = JSON.parse(window.sessionStorage.getItem("wpuserInfo") ).userId;//是否有登录信息
    let wpavailableAmount ='';
    let wpuserToken=window.sessionStorage.getItem('wpuserToken');
    let quickImg=[//支持银行路径
            {img:'../lib/images/bank/gs-bank.png',bankCode:'ICBC'},
            {img:'../lib/images/bank/ny-bank.png',bankCode:'ABC'},
            {img:'../lib/images/bank/js-bank.png',bankCode:'CCB'},
            {img:'../lib/images/bank/ms-bank.png',bankCode:'CMBC'},
            {img:'../lib/images/bank/traffic-bank.png',bankCode:'BOCOM'},
            {img:'../lib/images/bank/zs-bank.png',bankCode:'CMB'},
            {img:'../lib/images/bank/china-bank.png',bankCode:'BOC'},
            {img:'../lib/images/bank/xingye-bank.png',bankCode:'CIB'},
            {img:'../lib/images/bank/guangda-bank.png',bankCode:'CEB'},
            {img:'../lib/images/bank/safar-bank.png',bankCode:'PAB'},
            {img:'../lib/images/bank/zhongxin-bank.png',bankCode:'CNCB'},
            {img:'../lib/images/bank/beijing-bank.png',bankCode:'BCCB'},
            {img:'../lib/images/bank/guangfa-bank.png',bankCode:'GDB'},
            {img:'../lib/images/bank/youzhneg-bank.png',bankCode:'PSBC'},
            {img:'../lib/images/bank/shanghai-bank.png',bankCode:'BOS'},
            {img:'../lib/images/bank/huaxia-bank.png',bankCode:'HXB'},
            {img:'../lib/images/bank/pudong-bank.png',bankCode:'SPDB'},
            {img:'../lib/images/bank/guangfa-bank.png',bankCode:'GDB'},
            {img:'../lib/images/bank/shenfa-bank.png',bankCode:'SDB'},
        ];
    //获取用户银行卡信息
    function getuserJson() {
        var json = {
            "faceCode":"recharge/getTXBankInfo",
            "token":wpuserToken,    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                "userId":userId,
                "type":'2'
            }
        }
        return json;
    }//提现申请
    function rechargeApply(amount,payPwd) {
        var json = {
            "faceCode":"recharge/rechargeApply",//提现接口
            "token":wpuserToken,    
            "clientInfo":"W,100,IE8",  
            "requestTime": formatDateTime(startTime),
            "body":{
                "userId":userId,
                "amount":amount,
                "payPwd":payPwd
            }
        }
        return json;
    }
    $.ajax({  
        type: "POST",
        url: httpServer+"recharge/getTXBankInfo",
        headers:{
            'Access-Control-Allow-Origin':'*'
        }, 
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(getuserJson()),
        dataType: "json",
        success: function (amountShow) {  
         if(amountShow.resCode!='0'){
           
            oneError(amountShow)
         }else{
            amountShow=amountShow.body;
            let imgSrc='';
            for(var i=0;i<quickImg.length;i++){
                if(quickImg[i].bankCode==amountShow.bankCode){
                    imgSrc=quickImg[i].img;
                }
            }
            wpavailableAmount=parseFloat(amountShow.accountAmount);
            $('#wpavailableAmount').text(amountShow.accountAmount);
            amountShow.bankCardNo= (amountShow.bankCardNo).substr(0,4)+"****"+(amountShow.bankCardNo).substr(-4);
            $('#bankImg').html(` <img src="${imgSrc}" ><span>${amountShow.bankName}（${amountShow.bankCardNo}）</span>`)
         }
        },
        error: function(error){  
            console.log(error,1);  
        }    
    }); 
    
   //确认提现
    function withdrawalShow(){
        let withdrawMoney=$('#withdrawMoney').val().trim();
        let withdPwd=$('#maskInput').val().trim();
       if(withdrawMoney!=''){
            if(moneyNum.test(withdrawMoney)){
                if(parseFloat(withdrawMoney)<100){
                    $('#warnMoney').text('100元起提现，请确认提现金额')
                }else{
                    if(parseFloat(withdrawMoney)>(wpavailableAmount)*1){
                            $('#warnMoney').text('可用余额不足')
                    }else{
                        $('#withdrawalMask').show()
                        if(withdPwd!=''){
                            if(payPwd.test(withdPwd)){
                                   
                                    $.ajax({  
                                        type: "POST",
                                        url: httpServer+"recharge/rechargeApply",
                                        headers:{
                                            'Access-Control-Allow-Origin':'*'
                                        }, 
                                        async:false,
                                        contentType: "application/json; charset=utf-8",
                                        data: JSON.stringify(rechargeApply(withdrawMoney,withdPwd)),
                                        dataType: "json",
                                        success: function (getBankShow) {  
                                            if(getBankShow.resCode!='0' ){
                                               // oneError(getBankShow)
                                               $('#maskWarneding').text(getBankShow.errorMsg);
                                            }else{
                                                $('#withdrawalMask').hide();
                                                $('#rechargeCash').show()
                                               // window.location.href="index.html";
                                            }
                                        },
                                        error: function(error){  
                                            console.log(error,1);  
                                        }    
                                    });
                            }else{
                                $('#maskWarneding').text('交易密码不正确，请检查')
                            }
                        }else{
                            //$('#maskWarneding').text('交易密码不正确，请检查')
                        }
                    }
                }
           }else{
                $('#warnMoney').text('请输入正确提现金额')
           }
       }else{
         $('#warnMoney').text('100元起提现，请确认提现金额')
       }
    } 
    //全部提现
    function allAmount(){
        $('#withdrawMoney').val( $('#wpavailableAmount').text() );
    }
    //提现密码按钮
    function okWithdrawal(){
        let withdPwd=$('#maskInput').val().trim();
        if(withdPwd!=""){
            if(payPwd.test(withdPwd)){
                //withdrawalHide();
                withdrawalShow()
            }else{
                $('#maskWarneding').text('交易密码不正确，请检查');
            }
        }else{
            $('#maskWarneding').text('交易密码不正确，请检查')
        }
    }
    //获取焦点清空错误提示
    $('#maskInput').focus(function(){
        $('#maskWarneding').text('')
    })
    $('#withdrawMoney').focus(function(){
        $('#warnMoney').text('')
    })
    //弹框清除错误提示
    function withdrawalHide(){
        $('#maskInput').val('')
        $('#maskWarneding').text('')
        $('#withdrawalMask').hide()
    }  
</script>
</body>
</html>